package expressions.slogo;

import java.util.List;
import parsing.Token;
import model.Turtle;
import model.Angle;

/**
 * Turns the turtle right the given degrees.
 */
@Token(regex = "right|rt")
public class Right extends TurtleCommand
{

    public Right()
    {
        super(1);
    }

    @Override
    protected Double combineResults(List<Double> results, ITurtleContext context)
    {
        Turtle t = context.getTurtle();

        /*
         * Assume that the user gives the angle in degrees. So, convert the
         * given angle to radians.
         */
        double degrees = results.get(0);
        double delta = Angle.degreesToRadians(degrees);

        t.turn(t.getAngle().getRadians() - delta);

        /*
         * I think the spec calls for this to be returned in degrees and not
         * radians.
         */
        return Angle.radiansToDegrees(delta);
    }

}
